package controller

import (
	"admin/model"
	"common/helper"
	"encoding/json"
	g "github.com/doug-martin/goqu/v9"
	"github.com/valyala/fasthttp"
	"strconv"
)

type GameConfigController struct{}

// 游戏配置列表
func (that GameConfigController) List(ctx *fasthttp.RequestCtx) {

	page := ctx.QueryArgs().GetUintOrZero("page")
	pageSize := ctx.QueryArgs().GetUintOrZero("page_size")
	class := ctx.QueryArgs().GetUintOrZero("class")
	ex := g.Ex{"class": class}
	ex["display"] = 1
	s, err := model.GameConfigList(uint(page), uint(pageSize), ex)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, s)
}

// 游戏配置列表单个
func (that GameConfigController) GameConfigSingle(ctx *fasthttp.RequestCtx) {

	ckey := ctx.QueryArgs().GetUintOrZero("ckey")
	s := model.GameConfigByType(ckey)
	helper.RetData(ctx, true, s)
}

// 游戏配置更新
func (that GameConfigController) Update(ctx *fasthttp.RequestCtx) {

	param := model.TblGameConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("游戏配置更新", ctx)
	err = model.GameConfigUpdate(param.Id, param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) WeekConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetWeekConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateWeekConfig(ctx *fasthttp.RequestCtx) {
	param := model.UpdateWeekConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("周亏损配置更新", ctx)
	err = model.UpdateGetWeekConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteWeekConfig(ctx *fasthttp.RequestCtx) {
	param := model.UpdateWeekConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("周亏损配置删除", ctx)
	err = model.UpdateGetWeekConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DailyConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetDailyConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateDailyConfig(ctx *fasthttp.RequestCtx) {
	param := model.UpdateDailyConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("周亏损配置更新", ctx)
	err = model.UpdateDailyConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteDailyConfig(ctx *fasthttp.RequestCtx) {
	param := model.UpdateDailyConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("周亏损配置删除", ctx)
	err = model.UpdateDailyConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DepositConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetDepositConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateDepositConfig(ctx *fasthttp.RequestCtx) {
	param := model.DepositAward{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("累计充值配置更新", ctx)
	err = model.UpdateDepositConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteDepositConfig(ctx *fasthttp.RequestCtx) {
	param := model.DepositAward{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("累计充值配置删除", ctx)
	err = model.UpdateDepositConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DepositDivide(ctx *fasthttp.RequestCtx) {
	s, err := model.GetDepositDivide()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateDepositDivide(ctx *fasthttp.RequestCtx) {
	param := model.DepositDivide{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("充值分成配置更新", ctx)
	err = model.UpdateDepositDivide(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteDepositDivide(ctx *fasthttp.RequestCtx) {
	param := model.DepositDivide{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("充值分成配置删除", ctx)
	err = model.UpdateDepositDivide(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) InviteConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetInviteConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateInviteConfig(ctx *fasthttp.RequestCtx) {
	param := model.ProxyInviteBonus{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("邀请梯度配置更新", ctx)
	err = model.UpdateInviteConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteInviteConfig(ctx *fasthttp.RequestCtx) {
	param := model.ProxyInviteBonus{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("邀请梯度配置删除", ctx)

	err = model.UpdateInviteConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DepositInviteConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetDepositInviteConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateDepositInviteConfig(ctx *fasthttp.RequestCtx) {
	param := model.ProxyDepositInviteBonus{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("首充邀请梯度配置更新", ctx)
	err = model.UpdateDepositInviteConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteDepositInviteConfig(ctx *fasthttp.RequestCtx) {
	param := model.ProxyDepositInviteBonus{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("首充邀请梯度配置删除", ctx)

	err = model.UpdateDepositInviteConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) UnbindConfig(ctx *fasthttp.RequestCtx) {
	param := model.UnbindConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetUnbindConfig(param, ctx)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateUnbindConfig(ctx *fasthttp.RequestCtx) {
	param := model.UnbindConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("掉绑比例配置更新", ctx)

	err = model.UpdateUnbindConfig(param, ctx, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteUnbindConfig(ctx *fasthttp.RequestCtx) {
	param := model.UnbindConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("掉绑比例配置删除", ctx)

	err = model.UpdateUnbindConfig(param, ctx, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) PlatformsList(ctx *fasthttp.RequestCtx) {
	platform_type := ctx.QueryArgs().GetUintOrZero("platform_type")

	s, err := model.GetPlatformByPid(strconv.Itoa(platform_type))
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) SynRedis(ctx *fasthttp.RequestCtx) {
	model.SynRedis(ctx)
	model.GameFlushAll()
	model.BannerFlushCache()
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakePgList(ctx *fasthttp.RequestCtx) {
	param := model.FakePgConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetFakePgList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakePg(ctx *fasthttp.RequestCtx) {
	param := model.FakePgConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏更新", ctx)
	err = model.UpdateFakePgConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakePg(ctx *fasthttp.RequestCtx) {
	param := model.FakePgConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏删除", ctx)
	err = model.UpdateFakePgConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakePgRouteList(ctx *fasthttp.RequestCtx) {
	param := model.FakePgConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetFakePgRouteList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakePgRoute(ctx *fasthttp.RequestCtx) {
	param := model.FakePgRouteConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏线路更新", ctx)
	err = model.UpdateFakePgConfigRoute(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakePgRoute(ctx *fasthttp.RequestCtx) {
	param := model.FakePgRouteConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏线路删除", ctx)
	err = model.UpdateFakePgConfigRoute(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakePpRouteList(ctx *fasthttp.RequestCtx) {
	param := model.FakePpConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetFakePpRouteList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakePpRoute(ctx *fasthttp.RequestCtx) {
	param := model.FakePpRouteConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PP游戏线路更新", ctx)
	err = model.UpdateFakePpConfigRoute(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakePpRoute(ctx *fasthttp.RequestCtx) {
	param := model.FakePgRouteConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PP游戏线路删除", ctx)
	err = model.UpdateFakePgConfigRoute(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakePgCtrlList(ctx *fasthttp.RequestCtx) {
	param := model.FakePgCtrlConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetFakePgCtrlList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakePgCtrl(ctx *fasthttp.RequestCtx) {
	param := model.FakePgCtrlConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏调控更新", ctx)
	err = model.UpdateFakePgCtrlConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakePgCtrl(ctx *fasthttp.RequestCtx) {
	param := model.FakePgCtrlConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假PG游戏调控删除", ctx)
	err = model.UpdateFakePgCtrlConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakePpList(ctx *fasthttp.RequestCtx) {
	param := model.FakePpConfigParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetFakePpList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakePp(ctx *fasthttp.RequestCtx) {
	param := model.FakePpConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假Pp游戏更新", ctx)
	err = model.UpdateFakePpConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakePp(ctx *fasthttp.RequestCtx) {
	param := model.FakePpConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假Pp游戏删除", ctx)
	err = model.UpdateFakePpConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) ThirdTax(ctx *fasthttp.RequestCtx) {
	s, err := model.GetThirdTax()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateThirdTax(ctx *fasthttp.RequestCtx) {
	param := model.ThirdTax{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("抽税白名单编辑更新", ctx)
	err = model.UpdateThirdTax(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FlowConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetFlowConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFlowConfig(ctx *fasthttp.RequestCtx) {
	param := model.FlowConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	err = model.UpdateFlowConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) TaxConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetTaxConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateTaxConfig(ctx *fasthttp.RequestCtx) {
	param := model.TaxConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("抽税配置更新", ctx)
	err = model.UpdateTaxConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteTaxConfig(ctx *fasthttp.RequestCtx) {
	param := model.TaxConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("抽税配置删除", ctx)
	err = model.UpdateTaxConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) AddwageConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetAddwageConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateAddwageConfig(ctx *fasthttp.RequestCtx) {
	param := model.AddwageConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("加码配置更新", ctx)
	err = model.UpdateAddwageConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteAddwageConfig(ctx *fasthttp.RequestCtx) {
	param := model.AddwageConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("加码配置删除", ctx)
	err = model.UpdateAddwageConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) ValidwageConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetValidwageConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateValidwageConfig(ctx *fasthttp.RequestCtx) {
	param := model.ValidwageConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("打码配置更新", ctx)
	err = model.UpdateValidwageConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteValidwageConfig(ctx *fasthttp.RequestCtx) {
	param := model.ValidwageConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("打码配置删除", ctx)
	err = model.UpdateValidwageConfig(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) ActiveSwitchConfig(ctx *fasthttp.RequestCtx) {
	s, err := model.GetActiveSwitchConfig()
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateActiveSwitchConfigConfig(ctx *fasthttp.RequestCtx) {
	param := model.ActiveSwitch{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("活动开关更新", ctx)
	err = model.UpdateActiveSwitchConfigConfig(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakepgConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakepgConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {
		helper.RetData(ctx, false, "参数错误")
		return
	}

	s, err := model.GetFakepgConfig(param, ctx)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakepgConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakepgConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假pg rtp配置更新", ctx)
	err = model.UpdateFakepgConfig(param, ctx, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakepgConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakepgConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假pg rtp配置删除", ctx)
	err = model.UpdateFakepgConfig(param, ctx, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) FakeppConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakeppConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {
		helper.RetData(ctx, false, "参数错误")
		return
	}

	s, err := model.GetFakeppConfig(param, ctx)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateFakeppConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakeppConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假pp rtp配置更新", ctx)
	err = model.UpdateFakeppConfig(param, ctx, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteFakeppConfig(ctx *fasthttp.RequestCtx) {
	param := model.FakeppConfig{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("假pp rtp配置删除", ctx)
	err = model.UpdateFakeppConfig(param, ctx, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) BlackBankCardList(ctx *fasthttp.RequestCtx) {
	param := model.BlackBankCardParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetBlackBankCardList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateBlackBankCard(ctx *fasthttp.RequestCtx) {
	param := model.BlackBankCard{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("银行账号黑名单编辑", ctx)
	err = model.UpdateBlackBankCard(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteBlackBankCard(ctx *fasthttp.RequestCtx) {
	param := model.BlackBankCard{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("银行账号黑名单删除", ctx)
	err = model.UpdateBlackBankCard(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) BlackEmailList(ctx *fasthttp.RequestCtx) {
	param := model.BlackEmailParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	s, err := model.GetBlackEmailList(param)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, s)
}

func (that GameConfigController) UpdateBlackEmail(ctx *fasthttp.RequestCtx) {
	param := model.BlackEmail{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("邮箱账号黑名单编辑", ctx)
	err = model.UpdateBlackEmail(param, 0)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}

func (that GameConfigController) DeleteBlackEmail(ctx *fasthttp.RequestCtx) {
	param := model.BlackEmail{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	model.InsertLog("邮箱账号黑名单删除", ctx)
	err = model.UpdateBlackEmail(param, 1)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}
	helper.RetData(ctx, true, "成功")
}
